/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.applicatioN.entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Slim
 */
@Entity
@Table(name = "travailler_avec")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TravaillerAvec.findAll", query = "SELECT t FROM TravaillerAvec t"),
    @NamedQuery(name = "TravaillerAvec.findByDateDeDebut", query = "SELECT t FROM TravaillerAvec t WHERE t.dateDeDebut = :dateDeDebut"),
    @NamedQuery(name = "TravaillerAvec.findByDateDeFin", query = "SELECT t FROM TravaillerAvec t WHERE t.dateDeFin = :dateDeFin"),
    @NamedQuery(name = "TravaillerAvec.findByNomGrade", query = "SELECT t FROM TravaillerAvec t WHERE t.travaillerAvecPK.nomGrade = :nomGrade"),
    @NamedQuery(name = "TravaillerAvec.findByTravaillerAvecPK", query = "SELECT t FROM TravaillerAvec t WHERE t.travaillerAvecPK = :travaillerAvecPK"),
    @NamedQuery(name = "TravaillerAvec.findByNumeroDeMatricule", query = "SELECT t FROM TravaillerAvec t WHERE t.travaillerAvecPK.numeroDeMatricule = :numeroDeMatricule")})
public class TravaillerAvec implements Serializable {

    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected TravaillerAvecPK travaillerAvecPK;
    @Basic(optional = false)
    @Column(name = "DATE_DE_DEBUT")
    @Temporal(TemporalType.DATE)
    private Date dateDeDebut;
    @Column(name = "DATE_DE_FIN")
    @Temporal(TemporalType.DATE)
    private Date dateDeFin;
    @JoinColumn(name = "NUMERO_DE_MATRICULE", referencedColumnName = "NUMERO_DE_MATRICULE", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Agent agent;
    @JoinColumn(name = "NOM_GRADE", referencedColumnName = "NOM_GRADE", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Grade grade;

    public TravaillerAvec() {
    }

    public TravaillerAvec(TravaillerAvecPK travaillerAvecPK) {
        this.travaillerAvecPK = travaillerAvecPK;
    }

    public TravaillerAvec(TravaillerAvecPK travaillerAvecPK, Date dateDeDebut) {
        this.travaillerAvecPK = travaillerAvecPK;
        this.dateDeDebut = dateDeDebut;
    }

    public TravaillerAvec(String nomGrade, int numeroDeMatricule) {
        this.travaillerAvecPK = new TravaillerAvecPK(nomGrade, numeroDeMatricule);
    }

    public TravaillerAvecPK getTravaillerAvecPK() {
        return travaillerAvecPK;
    }

    public void setTravaillerAvecPK(TravaillerAvecPK travaillerAvecPK) {
        this.travaillerAvecPK = travaillerAvecPK;
    }

    public Date getDateDeDebut() {
        return dateDeDebut;
    }

    public void setDateDeDebut(Date dateDeDebut) {
        this.dateDeDebut = dateDeDebut;
    }

    public Date getDateDeFin() {
        return dateDeFin;
    }

    public void setDateDeFin(Date dateDeFin) {
        this.dateDeFin = dateDeFin;
    }

    public Agent getAgent() {
        return agent;
    }

    public void setAgent(Agent agent) {
        this.agent = agent;
    }

    public Grade getGrade() {
        return grade;
    }

    public void setGrade(Grade grade) {
        this.grade = grade;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (travaillerAvecPK != null ? travaillerAvecPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TravaillerAvec)) {
            return false;
        }
        TravaillerAvec other = (TravaillerAvec) object;
        if ((this.travaillerAvecPK == null && other.travaillerAvecPK != null) || (this.travaillerAvecPK != null && !this.travaillerAvecPK.equals(other.travaillerAvecPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.applicatioN.entities.TravaillerAvec[ travaillerAvecPK=" + travaillerAvecPK + " ]";
    }
}
